package com.atguigu.edustat.controller;


import com.atguigu.commonutils.R;
import com.atguigu.edustat.service.DailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author lhl
 * @since 2022-07-14
 */
@RestController
@RequestMapping("/edustat/daily")
@CrossOrigin
public class DailyController {
    @Autowired
    DailyService dailyService;
    @PostMapping("/createData/{day}")
    public R createStatisticsByDate(@PathVariable String day) {
        dailyService.createStatisticsByDay(day);
        return R.ok();
    }
    // 显示图表数据
    @GetMapping("show-chart/{type}/{begin}/{end}")
    public R showChart(@PathVariable String type, @PathVariable String begin, @PathVariable String end){
        Map<String, Object> map = dailyService.getChartData(begin, end, type);
        return R.ok().data(map);
    }
}

